package abc.secgroup.music_backend.service.impl;

import abc.secgroup.music_backend.entity.UserDO;
import abc.secgroup.music_backend.repository.UserRepository;
import abc.secgroup.music_backend.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service(value = "UserService")
public class UserServiceImpl implements UserService {

    public final UserRepository userRepository;

    @Autowired
    public UserServiceImpl(UserRepository userRepository) {
        this.userRepository = userRepository;
    }

    @Override
    public boolean AuthUser(UserDO user) {
        return AuthUser(user.getAccount(),user.getPassword());
    }

    @Override
    public boolean AuthUser(String account, String password) {
        UserDO user = userRepository.findUserDOByAccount(account);
        if(user==null){
            return false;
        }
        return user.getPassword().equals(password);
    }
}
